<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 如何合并对象
        var obj = {
            a:1,
            b:2
        }

        var obj2 = {
            c:3,
            d:4
        }

        // 将obj和obj2 合并成一个对象
        var newObj = {};

        for(var item in obj){
            // console.log(item); //a,b
            newObj[item] = obj[item];
        }
        
        for(var item in obj2){
            // console.log(item); //c,d
            newObj[item] = obj2[item];
        }

        console.log(newObj);


    </script>
</body>
</html>